home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Amos / MonsterEnemy / ROBOT.AMOS / ROBOT.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1992-06-01  |  15.2 KB  |  243 lines

  1. ' This is another END OF LEVEL monster artificial  
  2. ' intelligence routine that can be incorperated
  3. ' into your own games. This time we have a GIANT 
  4. ' ROBOT character that shoots fireballs at YOU!
  5. ' Its been ripped from Charlie Chimp in the nuclear
  6. ' power station levels.  
  7. '
  8. ' Has anyone out there got this far in Charlie Chimp?
  9. '
  10. ' Better still - has anyone finished Charlie Chimp 
  11. ' without using cheat modes? 
  12.  
  13. Priority Reverse On : Rem This command allows us to reverse the order of which BOBS are placed on the screen so that the two fireballs appear behind the gun instead of in front of it!! 
  14.  
  15. Screen Open 0,320,256,16,Lowres : Rem open up the initial screen 
  16.  
  17. Flash Off : Curs Off : Cls 0 : Rem tidy the display 
  18.  
  19. Hide On : Rem hide the mouse pointer 
  20.  
  21. Get Sprite Palette : Rem get the proper colours 
  22.  
  23. Double Buffer : Rem stop the flickering
  24.  
  25.  
  26. ' *********************************************************************
  27. ' * This next lot sets up all the bobs and channels that will be used *
  28. ' *********************************************************************
  29.  
  30. For N=1 To 6 : Rem Set up a loop from 1 to 6
  31.  
  32. Channel N To Bob N : Rem Tell AMAL channel N to start using bob N 
  33.  
  34. Next N : Rem Repeat the loop
  35.  
  36. ' *****************************************************************
  37. ' * The actual graphics for the robot are split into four pieces. *
  38. ' * These are the main body, a backpack, the flames and the gun.  *
  39. ' * Everything is centered around the main body which is BOB      *
  40. ' * number 1.                                                     *
  41. ' *****************************************************************
  42.  
  43. Bob 1,130,-200,92 : Rem This is the starting point of the main body on the screen
  44.  
  45. For N=2 To 6 : Rem Set up a loop from 2 to 6
  46.  
  47. Bob N,,, : Rem Place BOB N on the screen  
  48.  
  49. Next N : Rem Repeat the loop
  50.  
  51. ' **************************************************************** 
  52. ' * This is the string that controls the MAIN BODY of the robot. * 
  53. ' **************************************************************** 
  54.  
  55. ' Here is a list of the variables (Or registers) that are used throughout
  56. ' the different AMAL programs. 
  57.  
  58. ' If RW=-1 then the ROBOT is facing left 
  59. ' If RW=1 then the ROBOT is facing right 
  60. '
  61. ' RT will always hold the X coardinate of the main body so that all the other parts can be centered around it
  62. ' RU will always hold the Y coardinate of the main body so that all the other parts can be centered around it
  63.  
  64. ' RV when set to 2 tells FIREBALL number 2 that FIREBALL number 1 has decided to fire so join in!! 
  65. ' RV when set to zero means that both fireballs have went off the screen so that they can decide to refire!
  66.  
  67. ' ****************************************************************** 
  68. ' * These first three lines of the string control the ROBOT coming * 
  69. ' * into the screen initially.                                     * 
  70. ' ****************************************************************** 
  71.  
  72.           _MAIN_BODY$="Let RS=0;Anim 1,(1,10);Let RW=-1;" : Rem Reset RS to 0, Tell the string to use image number 1 from the sprite bank and set RW to -1 which means the robot is facing left!!
  73. _MAIN_BODY$=_MAIN_BODY$+"label A:Let Y=Y+1;Let RT=X;Let RU=Y;" : Rem This moves the main body part down the screen and tells RT and RU what its coardinates are so that all the other parts can be centered around it 
  74. _MAIN_BODY$=_MAIN_BODY$+"If Y=80 Jump label B;Pause;Jump label A;" : Rem Once Y is equal to 80 we jump to the routine that will move the ROBOT to the left
  75.  
  76. ' *************************************************************************
  77. ' * These next two lines control the ROBOT moving to the left until its   *
  78. ' * X coardinates are less than -66. At this point it jumps to label D.   *
  79. ' * When it gets to here it selects a RANDOM Y coardinate and pauses      *
  80. ' * for a second. The image is then horiztontally reversed using the      *
  81. ' * command $8000+1 which tells AMOS to use a flipped version of image 1. *
  82. ' *************************************************************************
  83.  
  84. _MAIN_BODY$=_MAIN_BODY$+"label B:Pause;Let X=X-1;" : Rem Move the ROBOT to the left 1 pixel at a time 
  85. _MAIN_BODY$=_MAIN_BODY$+"Let RT=X;If X<-66 Jump label D;Jump label B;" : Rem RT is set to the same value of X so that the other channels can get the main bodys X cordinates. When X is less than -66 it jumps to label D 
  86.  
  87. ' *************************************************************************
  88. ' * These next two lines control the ROBOT moving to the right until its  *
  89. ' * X coardinates are more than 370. At this point it jumps to label E.   *
  90. ' * When it gets to here it selects a RANDOM Y coardinate and pauses      *
  91. ' * for a second. The image is then flipped back to normal using the      *
  92. ' * normal AMAL ANIMATION command Anim 1,(1,10).                          *
  93. ' *************************************************************************
  94.  
  95. _MAIN_BODY$=_MAIN_BODY$+"label C:Pause;L X=X+1" : Rem Move the ROBOT to the right 1 pixel at a time
  96. _MAIN_BODY$=_MAIN_BODY$+"Let RT=X;If X>370 Jump label E;Jump label C;" : Rem RT is set to the same value of X so that the other channels can get the main bodys X coardinates. When X is greater than 370 it jumps to label E 
  97.  
  98. ' ***********************************************************************
  99. ' * This next bit handles the ROBOT when it has went off the LEFT side  *
  100. ' * of the screen. At this point a RANDOM Y coardinate is selected      *
  101. ' * using the AMAL function - Let Y=Z(160). This will select a new      *
  102. ' * Y coardinate between 0 and 180. RU is then set to this value as well*    
  103. ' * so that the other AMAL channels know the new Y coardinate of the    *
  104. ' * main body. RW is set to 1 which tells us that the ROBOT is now      *
  105. ' * facing to the right.                                                *
  106. ' ***********************************************************************
  107.  
  108. _MAIN_BODY$=_MAIN_BODY$+"label D:Let RW=1;Let Y=Z(160);" : Rem Set RW to 1 so that we know the ROBOT is facing right and select a new Y coardinate for him
  109. _MAIN_BODY$=_MAIN_BODY$+"Let RU=Y;Anim 1,($8000+1,10);" : Rem Set RU to the new Y coardinate and set the ANIMATION to show image 1 flipped using $8000+1 
  110. _MAIN_BODY$=_MAIN_BODY$+"Let R0=Z(40);For R1=0 To R0; Pause;Next R1;Jump label C;" : Rem This line will pause for a random amount of VBL's before jumping to label C which controls the ROBOT moving right
  111.  
  112. ' ***********************************************************************
  113. ' * This next bit handles the ROBOT when it has went off the RIGHT side *
  114. ' * of the screen. At this point a RANDOM Y coardinate is selected      *
  115. ' * using the AMAL function - Let Y=Z(160). This will select a new      *
  116. ' * Y coardinate between 0 and 180. RU is then set to this value as well*    
  117. ' * so that the other AMAL channels know the new Y coardinate of the    *
  118. ' * main body. RW is set to 1 which tells us that the ROBOT is now      *
  119. ' * facing to the right.                                                *
  120. ' ***********************************************************************
  121.  
  122. _MAIN_BODY$=_MAIN_BODY$+"label E:Let RW=-1;Let Y=Z(160);" : Rem Set RW To -1 so that we know the ROBOT is facing left and select a new Y coardinate for him
  123. _MAIN_BODY$=_MAIN_BODY$+"Let RU=Y;Anim 1,(1,10);" : Rem Set RU to the new Y coardinate andset the ANIMATION to show image 1 normal 
  124. _MAIN_BODY$=_MAIN_BODY$+"Let R0=Z(40);For R1=0 To R0;Pause;Next R1;Jump label B;" : Rem  This line will pause for a random amount of VBL's before jumping to label B which controls the ROBOT moving left  
  125.  
  126. ' *****************************************************************  
  127. ' * Next up we have the flames coming from the back of the ROBOT. *
  128. ' * Cutting large monsters into small bits like this not only     *
  129. ' * saves you memory and disk space but it also gives you extra   *
  130. ' * speed as AMOS is putting smaller sized BOBS on the screen     *
  131. ' * instead of one gigantic BOB!!                                 *
  132. ' *****************************************************************
  133.  
  134. ' ************************************************************************** 
  135. ' * These next two lines control the FLAMES when the ROBOT is moving left! * 
  136. ' ************************************************************************** 
  137.  
  138.        _FLAMES$="label C:Anim 0,(3,3)(4,3)(5,3)(4,3);" : Rem This bit sets up the ANIMATION frames of the flames when the ROBOT is moving to the left!  
  139. _FLAMES$=_FLAMES$+"label A:Let X=RT;Let Y=RU;If RW=1 Jump label B;Pause;Jump label A;" : Rem This line constantly centres the flames around the ROBOTS X and Y coardinates in RT and RU.
  140.  
  141. ' ***************************************************************************  
  142. ' * These next two lines control the FLAMES when the ROBOT is moving right! *  
  143. ' ***************************************************************************  
  144.  
  145. _FLAMES$=_FLAMES$+"label B:Anim 0,($8000+3,3)($8000+4,3)($8000+5,3)($8000+4,3);" : Rem This bit sets up the horizontally flipped ANIMATION frames of the flames when the ROBOT is moving to the right!
  146. _FLAMES$=_FLAMES$+"label E:Let X=RT;Let Y=RU;If RW=-1 Jump label C;Pause;Jump label E;" : Rem This line constantly centres the flames around the ROBOTS X and Y coardinates in RT and RU.
  147.  
  148. ' *******************************************************************  
  149. ' * This next part controls the ROBOTS gun when moving to the left. *  
  150. ' *******************************************************************
  151.  
  152.     _GUN$="label D:Anim 1,(6,10);" : Rem This part sets up the guns ANIMATION image for moving to the left  
  153. _GUN$=_GUN$+"label A:Let X=RT;Let Y=RU;If RW=1 Jump label B;Pause;Jump label A;" : Rem This constantly centres the GUN around the main body of the ROBOT by using the main bodys X and Y coardinates - placed in RT and RU. 
  154.  
  155. ' ********************************************************************   
  156. ' * This next part controls the ROBOTS gun when moving to the right. *   
  157. ' ******************************************************************** 
  158.  
  159. _GUN$=_GUN$+"label B:Anim 1,($8000+6,10);" : Rem This part sets uo the guns horizontally flipped ANIMATION image for moving to the right  
  160. _GUN$=_GUN$+"label C:Let X=RT;Let Y=RU;If RW=-1 Jump label D;Pause;Jump label C;" : Rem This constantly centres the GUN around the main body of the ROBOT by using the main bodys X and Y coardinates - placed in RT and RU. 
  161.  
  162. ' *****************************************************************    
  163. ' * The next few lines control the backpack on the ROBOT that the *  
  164. ' * flames come out of.                                           *
  165. ' *****************************************************************
  166.  
  167. ' ************************************************************   
  168. ' * These two lines control the backpack moving to the left. * 
  169. ' ************************************************************ 
  170.  
  171.          _BACKPACK$="label D:Anim 1,(2,10);" : Rem Set up the ANIMATION frame for moving left 
  172. _BACKPACK$=_BACKPACK$+"label A:Let X=RT;Let Y=RU;If RW=1 Jump label B;Pause;Jump label A;" : Rem Again we just centre the backpack around the main body of the ROBOT by setting it to the same X and Y coardinates of the main body - RT and RU 
  173.  
  174. ' *************************************************************    
  175. ' * These two lines control the backpack moving to the right. *  
  176. ' *************************************************************  
  177.  
  178. _BACKPACK$=_BACKPACK$+"label B:Anim 1,($8000+2,10);" : Rem Set up the horizontally flipped ANIMATION frame for moving right 
  179. _BACKPACK$=_BACKPACK$+"label C:Let X=RT;Let Y=RU;If RW=-1 Jump label D;Pause;Jump label C;" : Rem Again we just centre the backpack around the main body of the ROBOT by setting it to the same X and Y coardinates of the main body - RT and RU 
  180.  
  181. ' ***********************************
  182. ' * Here we have FIREBALL number 1. *  
  183. ' ***********************************
  184.  
  185. _FIREBALL1$="label R:Let RV=0;Let X=-500;Pause;Anim 0,(7,10);" : Rem This line places the fireball off the screen until it has been fired 
  186.  
  187. _FIREBALL1$=_FIREBALL1$+"label A: For R0=1 To 23; Next R0;" : Rem This just makes sure that there is a delay in the amount of fireballs that the ROBOT will shoot - so that the player in the game can kill the buggar!  
  188. _FIREBALL1$=_FIREBALL1$+"If Z(1000)>500 Jump label B;Jump label A;" : Rem This is the line that decides wheter the fireballs should be fired or not by selecting a RANDOM number!
  189.  
  190. _FIREBALL1$=_FIREBALL1$+"label B:Let RV=2;If RW=-1 Jump label C;" : Rem This tells the FIREBALL number 2 to FIRE - by setting RV to 2
  191. _FIREBALL1$=_FIREBALL1$+"Anim 0,(7,10);Let X=RT+20;Let Y=RU+35;Pause;Jump label D;" : Rem This sets up the fireball if its moving to the left and centers it around the main body and guns X and Y coardinates - RT+20 and RU+35 
  192.  
  193. _FIREBALL1$=_FIREBALL1$+"label C:Anim 0,($8000+7,10);Let X=RT-20;Let Y=RU+35;Pause;Jump label E;" : Rem This sets up the fireball if its moving to the right and centers it around the main body and guns X and Y caordinates - RT-20 and RU+35  
  194.  
  195. _FIREBALL1$=_FIREBALL1$+"label D:Pause;Let X=X+2;Let Y=Y-1;If X>340 Jump label R;Jump label D;" : Rem This moves the fireball to the right 
  196. _FIREBALL1$=_FIREBALL1$+"label E:Pause;Let X=X-2;Let Y=Y-1;If X<-30 Jump label R;Jump label E;" : Rem This moves the fireball to the left
  197.  
  198. ' ****************************** 
  199. ' * And last - but not least!. *   
  200. ' * We have Fireball number 2. * 
  201. ' ****************************** 
  202.  
  203. _FIREBALL2$="label R:Let X=-500;Pause;Anim 0,(7,10);" : Rem This line places the fireball off the screen until it has been fired 
  204.  
  205. ' ************************************************************************** 
  206. ' * This line checks to see if the register/variable RV has been set to 2. * 
  207. ' * If it has this means that FIREBALL number 1 has told it to fire so it  * 
  208. ' * jumps to label B and checks which direction the main body is facing.   * 
  209. ' ************************************************************************** 
  210.  
  211. _FIREBALL2$=_FIREBALL2$+"label A:Pause;If RV=2 Jump label B;Jump label A;" : Rem Constantly checks to see if it should fire 
  212.  
  213. _FIREBALL2$=_FIREBALL2$+"label B:If RW=-1 Jump label C;" : Rem Is the ROBOT facing to the right? If so then jump to label C which setsup the fireball moving to the right otherwise move on to next line!!  
  214.  
  215. _FIREBALL2$=_FIREBALL2$+"Anim 0,(7,10);Let X=RT+20;Let Y=RU+35;Pause;Jump label D;" : Rem This line sets up the fireball for moving to the left
  216.  
  217. _FIREBALL2$=_FIREBALL2$+"label C:Anim 0,($8000+7,10);Let X=RT-20;Let Y=RU+35;Pause;Jump label E;" : Rem This line sets up the fireball for moving to the right 
  218.  
  219. _FIREBALL2$=_FIREBALL2$+"label D:Pause;Let X=X+2;Let Y=Y+1;If X>340 Jump label R;Jump label D;" : Rem This line controls the fireball moving to the right
  220. _FIREBALL2$=_FIREBALL2$+"label E:Pause;Let X=X-2;Let Y=Y+1;If X<-30 Jump label R;Jump label E;" : Rem This line controls the fireball moving to the left 
  221.  
  222. ' ***************************************************************************
  223. ' * Set up the appropriate AMAL channels with the appropriate AMAL strings. *  
  224. ' ***************************************************************************
  225.  
  226. Amal 1,_MAIN_BODY$
  227. Amal 2,_FLAMES$
  228. Amal 3,_GUN$
  229. Amal 4,_BACKPACK$
  230. Amal 5,_FIREBALL1$
  231. Amal 6,_FIREBALL2$
  232.  
  233. ' *********************************************************
  234. ' * Don't tell me I have to tell you what this loop does? *
  235. ' *********************************************************
  236.  
  237. For N=1 To 6
  238. Amal On N
  239. Next N
  240.  
  241. Wait Vbl : Rem rem Give AMOS time to setup all of the above!
  242.  
  243. Direct : Rem go to direct mode